package main;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Graphics;
import java.awt.Polygon;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class PointOfInterest2 implements MouseListener {

	public Point place;
	public JLabel tooltip;
	public JPanel info;
	public JButton done = new JButton("DONE");
	
	public PointOfInterest2() {
		place = new Point(500, 100);
		
		tooltip = new JLabel("<html><center><b>The Statue Of Liberty<b/><br /><br />" +
        		"The Statue of Liberty (Liberty Enlightening the World " +
        		"is a colossal neoclassical sculpture on Liberty Island in New York " +
        		"Harbor, designed by Frédéric Bartholdi and dedicated on October 28," +
        		" 1886.<br /><br />" +
        		"<b>Click for more info</b><br /><br />" +
        		"Info taken from wikipedia.org</center></html>");
		tooltip.setPreferredSize(new Dimension(200, 400));
        tooltip.addMouseListener(this);
		
        info = new JPanel();
        info.setPreferredSize(new Dimension(800, 600));
        info.setLayout(new FlowLayout());
		
        JLabel label = new JLabel();
        label.setPreferredSize(new Dimension(800, 500));
        label.setFont(Fonts.default_font(22));
        label.setText("<html><center><b>The Statue of Liberty</b> (Liberty Enlightening " +
        		"the World) is a colossal neoclassical sculpture on Liberty Island" +
        		" in New York Harbor, designed by Frédéric Bartholdi and dedicated " +
        		"on October 28, 1886. The statue, a gift to the United States from " +
        		"the people of France, is of a robed female figure representing " +
        		"Libertas, the Roman goddess of freedom, who bears a torch and a " +
        		"tabula ansata (a tablet evoking the law) upon which is inscribed " +
        		"the date of the American Declaration of Independence. A broken chain" +
        		" lies at her feet. The statue has become an iconic symbol of freedom" +
        		" and of the United States.</center></html>");
        		
		done.setPreferredSize(new Dimension(800, 100));
		done.setFont(Fonts.default_font(48));
				
		info.add(label);
		info.add(done);
		
        done.addMouseListener(this);        
	}
	
	public void draw(Graphics g) {
		Polygon p = new Polygon();
		p.addPoint((int)place.x-10, (int)place.y);
		p.addPoint((int)place.x, (int)place.y-20);
		p.addPoint((int)place.x+10, (int)place.y);
		p.addPoint((int)place.x, (int)place.y+20);
				
		g.setColor(Color.ORANGE);
		
		g.fillPolygon(p);
	}

	@Override
	public void mouseClicked(MouseEvent arg0) {
		if (Simulator.timer.isRunning()) {
			return;
		}
		
		if (arg0.getSource().equals(tooltip)) {
			UserInterface.setContentPane(info);
			Simulator.setAnimation(false);
		} else if (arg0.getSource().equals(done)) {
			UserInterface.setContentPane(UserInterface.simulatorPanel);
		}
		
	}

	@Override
	public void mouseEntered(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseExited(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mousePressed(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseReleased(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}
	
}
